/**
 * Created by DELL on 2018-03-08.
 */
var baseFn = {
    formatDate:function(elm){
        if(String(elm).length == 1){
            return '0'+ String(elm)
        }
        return elm
    },
    uniqueArr:function(arr){
        var res = [];
        var json = {};
        for(var i = 0; i < arr.length; i++){
            if(!json[arr[i]]){
            res.push(arr[i]);
            json[arr[i]] = 1;
            }
        }
        return res;
    },
    dialog:function(options){
        //dialog's opts
        //dialog
        var defaults={
            title: '温馨提示',
            content: '生命的起源归于自然',
            okValue: '确定',
            ok: function(){},
            cancelValue: "取消",
            cancel: '' ,
            width:'250'
        }
        var settings = $.extend({}, defaults, options);
        var d = dialog(settings).showModal();
        return d
    },
    infoDialog:function(cnt,callback,times){
        //dialog's opts(提示内容，“确定ok”回调函数,显示时间间隔)
        //dialog
        var defaults={
            title: '提示',
            content: '对话框将在一秒内关闭',
            okValue: '确定',
            ok: function(){
                this.close()
                callback()
            },
            cancelValue: "取消",
            cancel: '' ,
            width:'250'
        }
        var _times=1000,_callback=function(){}
        if(times != undefined && times != ''){
            _times = times
        }
        if(callback != undefined && callback != ''){
            _callback = callback
        }
        var settings = $.extend({}, defaults, {content:cnt,callback:_callback,times:_times});
        
        var d = dialog(settings);
        d.show();
        setTimeout(function () {
            d.close().remove();
            settings.callback()
        }, settings.times);
    }

}